package com.dyh.quickdemo.demos.thre;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

/*
@Author=Joey Wheeler
@Date=2020/10/26 10:48
*/
@Slf4j
public class IntrpThre {

    @Test
    public void test() throws InterruptedException {
        Thread th = new Thread(()->{
            for (;;){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                log.info(Thread.currentThread().getName()+"sodayo");
            }
        });

        th.start();

        Thread.sleep(3000L);
        th.interrupt();//打断线程

    }
}
